package cn.doit.scala.day04.oob

/**
 * @DATE 2021/12/28/16:04
 * @Author MDK
 * @Version 2021.2.2
 * */
class C02Demo {

}
object C02Demo{
  def apply(x:Int, y:Int):Int={
    x+y
  }

  def apply():C02Demo={
    new C02Demo
  }

  def main(args: Array[String]): Unit = {
    //调用apply方法的两种方式
    val res = C02Demo.apply(2, 4)
    val res2 = C02Demo(2, 4)
    println(res)
    println(res2)

    println("============返回一个C02Demo对象==============")
    val demo: C02Demo = C02Demo()

  }
}
